﻿@{
    //ViewBag.Title = "_LayuiEdit";
    Layout = "~/Views/Shared/_LayuiMain.cshtml";
}
<script type="text/javascript">
    
    var form, formModel,
        beforeSaveHandler, /** 当form进行提交前触发,用于重置上传postdata对象*/
        beforeLoadHandler; /** 当载入form值前触发，用于载入前重置formdata*/
        
    addLayuiApp("form");
    addLayuiUseEvent(function () {
        form = layui.form;
        if (parent.EditModel) {
           formModel = {};
            $.extend(true, formModel, parent.EditModel);
            form.val("form", formModel);
        }
        form.on("submit(save)", function (formData) {            
            var SaveUrl = "@ViewBag.SaveUrl";
            var postData;
            if (beforeSaveHandler) {
                postData = beforeSaveHandler(formData.field);
            } else {
                postData = formData.field;
            }
            jqJsonPost(SaveUrl,
                postData,
                function (rData) {
                    layer.msg(rData.msg);
                    if (rData.code == 0) {
                        //刷新父页面
                        if (parent.tableReload)
                        {
                            parent.tableReload();
                            parent.layer.closeAll("iframe");
                        }
                    }
                });
            return false;
        })
    });
</script>
@RenderBody()